"use strict";
const { Model } = require("sequelize");
const { IdGenerator } = require("../utils/idGenerator");
module.exports = (sequelize, DataTypes) => {
  class Setting extends Model {
    /**
     * Helper method for defining associations.
     * This method is not a part of Sequelize lifecycle.
     * The `models/index` file will call this method automatically.
     */
    static associate(models) {
      // define association here
    }
  }

  Setting.init(
    {
      id: {
        type: DataTypes.INTEGER.UNSIGNED, // 无符号整数类型
        allowNull: false,
        primaryKey: true,
        defaultValue: function () {
          return IdGenerator.getNextID(); // 使用封装的ID生成方法
        },
      },
      name: DataTypes.STRING,
      icp: DataTypes.STRING,
      copyright: DataTypes.STRING,
    },
    {
      sequelize,
      modelName: "Setting",
    },
  );
  return Setting;
};
